home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / Peon / PeonSDK-Win32-1.0.0.exe / {app} / PeonMain / include / Matrix44.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-11-25  |  2.3 KB  |  82 lines

  1.  
  2. #ifndef _MATRIX44_H_
  3. #define _MATRIX44_H_
  4. /*
  5. Peon - Win32 Games Programming Library
  6. Copyright (C) 2002-2005 Erik Yuzwa
  7.  
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12.  
  13. This library is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. Library General Public License for more details.
  17.  
  18. You should have received a copy of the GNU Library General Public
  19. License along with this library; if not, write to the Free
  20. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  
  22. Erik Yuzwa
  23. peon AT wazooinc DOT com
  24. */
  25.  
  26. #include "Peonstdafx.h"
  27. #include "Vector3.h"
  28.  
  29. namespace peon
  30. {
  31.  
  32.     /**
  33.     * This is a bare-bones Matrix object which is of size 4x4. 
  34.     * It's not optimized, so use at your own risk but it demonstrates
  35.     * how to use some basic matrix operations.
  36.     *
  37.     * The matrix is column-major which is exactly how the matrices are
  38.     * represented in OpenGL. If you're porting this library over to 
  39.     * Direct3D, just remember that Direct3D's format is row-major.
  40.     */
  41.     class PEONMAIN_API Matrix44
  42.     {
  43.     public:
  44.  
  45.         /** our matrix data. It's in one contiguous element block. */
  46.         float m[16];
  47.  
  48.         Matrix44(){ }
  49.  
  50.         Matrix44( float m0, float m4, float  m8, float m12,
  51.                    float m1, float m5, float  m9, float m13,
  52.                    float m2, float m6, float m10, float m14,
  53.                    float m3, float m7, float m11, float m15 );
  54.  
  55.         void identity(void);
  56.         void translate(const Vector3 &trans);
  57.         void translate_x(const float &dist);
  58.         void translate_y(const float &dist);
  59.         void translate_z(const float &dist);
  60.         void rotate(const float &angle, Vector3 &axis);
  61.         void rotate_x(const float &angle);
  62.         void rotate_y(const float &angle);
  63.         void rotate_z(const float &angle);
  64.         void scale(const Vector3 &scale);
  65.         void transformPoint( Vector3 *vec );
  66.         void transformVector( Vector3 *vec );
  67.  
  68.         // Operators...
  69.         Matrix44 operator + (const Matrix44 &other);
  70.         Matrix44 operator - (const Matrix44 &other);
  71.         Matrix44 operator * (const Matrix44 &other);
  72.  
  73.         Matrix44 operator * (const float scalar);
  74.     };
  75.  
  76.  
  77.  
  78. }
  79.  
  80. #endif 
  81.  
  82.